package com.itheima.controller;

import com.itheima.common.PageBean;
import com.itheima.common.R;
import com.itheima.dto.EmpQueryDto;
import com.itheima.pojo.Emp;
import com.itheima.service.EmpService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/emps")
public class EmpController {

    @Autowired
    EmpService empService;

    //分页查询
    @GetMapping
    public R listEmp(EmpQueryDto dto) {
       PageBean pageBean = empService.pageQuery(dto);
       return R.ok(pageBean);
    }

    //批量删除员工
    @DeleteMapping
    public R deleteEmp(Integer[] ids) {
        empService.deleteEmp(ids);
        return R.ok();
    }

    //新增员工
    @PostMapping
    public R addEmp(@RequestBody Emp emp) {
        empService.addEmp(emp);
        return R.ok();
    }
}
